package object;

import java.util.Objects;

/** 点 */
public class Point {//get/set 快捷生成 alt+insert
    private int x;
    private int y;
    public Point() {}
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }




    @Override
    public boolean equals(Object o) {
        if (this == o) return true;//this = p1 , o = p2, 这里的对比是两个地址对比
        if (o == null || getClass() != o.getClass()) return false;// o有值所以≠null, gteClass默认调用Object的方法, o.gteClass也调用Object的方法, 所有两边相等
        Point point = (Point) o;//将Object类型o强转为Point类型o
        return x == point.x && y == point.y;//对比point p1 和point p2的XY的值
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }

    @Override
    public String toString() {//重写Object的toString方法
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';  //Point{x100,y=200}
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

}
